<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/js/rsa/jsencrypt.js}" type="text/javascript" ></script>
    <script th:src="@{/js/rsa/jquery.js}" type="text/javascript" ></script>

    <script th:src="@{/js/aes/components/core-min.js}" type="text/javascript"></script>
    <script th:src="@{/js/aes/components/enc-base64.js}" type="text/javascript"></script>
    <script th:src="@{/js/aes/components/cipher-core-min.js}" type="text/javascript"></script>
    <script th:src="@{/js/aes/components/mode-ecb.js}" type="text/javascript"></script>
    <script th:src="@{/js/aes/components/aes-min.js}" type="text/javascript"></script>


</head>
<body>
    <input type="text" th:value="${session.KEY_MAP.publicKey}" id="publicKey" />
    <input type="text" th:value="${session.KEY_MAP.privateKey}" id="privateKey"/>
    <h1>加密页面</h1>
</body>
</html>
<script>
    //AES加密
    function AESEncrypt(word,encodeRule) {
       var key= CryptoJS.enc.Utf8.parse(encodeRule);
       var srcs=CryptoJS.enc.Utf8.parse(word);
       var resultByte= CryptoJS.AES.encrypt(srcs,key,{mode:CryptoJS.mode.ECB,padding:CryptoJS.pad.Pkcs7});
       return resultByte.toString();
    }

    //AES解密
    function AESDecrypt(word,encodeRule) {
        var key=CryptoJS.enc.Utf8.parse(encodeRule);
        var resultByte=CryptoJS.AES.decrypt(word,key,{mode:CryptoJS.mode.ECB,padding:CryptoJS.pad.Pkcs7});
        return  CryptoJS.enc.Utf8.stringify(resultByte).toString()
    }

    //RSA加密
    function RSAEncrypt(word,publicKey){
        var encrypt=new JSEncrypt();
        encrypt.setPublicKey(publicKey);
        var data=encrypt.encrypt(word);
        return data;
    }
    //RSA解密
    function  RSADecrypt(word,privateKey) {
        var encrypt=new JSEncrypt();
        encrypt.setPrivateKey(privateKey);
        var data=encrypt.decrypt(word);
        return data;
    }







</script>
